﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
    xmlns:TableDataDictionary="ext:Data"
>
    <xsl:variable name="varStart" select="1"></xsl:variable>
    <xsl:variable name="varEnd" select="TableDataDictionary:GetValue('Count')"></xsl:variable>

    <xsl:template match="/">
        <html>
            <head>
                <title>Products TFS - Daily Matrix - <xsl:value-of select="TableDataDictionary:GetValue('TodayDate')"/>
            </title>
            </head>
            <body>
                <style type="text/css">
                    #ticketstable td{background-color:#FFF;padding:6px;text-align:left;}
                    #ticketstable .nameTD{text-align:left;}
                </style>
                <font face="calibri,arial">
                    <p>
                        Dear,
                    </p>
                    <p>
                        Here is the daily matrix.
                    </p>
                    <table id='ticketstable' cellspacing='1px' cellpadding='6px' border='0px' style='background-color:#ccc;'>
                        <font face="calibri,arial" size="-1">
                            <tr style='font-weight:bold;'> 
                                <td class='nameTD'>Name</td>
                                <td>Capacity</td>
                                <td>Expected</td>
                                <td>Time Spent</td>
                                <td>Completed Work</td>
                                <td>Total Estimate</td>
                                <td>Closed Tasks</td>
                            </tr>
                            <xsl:call-template name="for-loop">
                                <xsl:with-param name="i" select="$varStart"></xsl:with-param>
                                <xsl:with-param name="count" select="$varEnd"></xsl:with-param>
                            </xsl:call-template>
                        </font>
                    </table>
                    <br/>
                    <br/>
                    
                    Thank you.<br/>
                </font>
            </body>
        </html>
    </xsl:template>

    <xsl:template name="for-loop">
        <xsl:param name="i"></xsl:param>
        <xsl:param name="count"></xsl:param>

        <xsl:if test="$i &lt;= $count">
            <tr> 
                <td class="nameTD">
                    <xsl:value-of select="TableDataDictionary:GetTableDataValue($i, 'Name')"/>
                </td>
                <td>
                    <xsl:value-of select="TableDataDictionary:GetTableDataValue($i, 'Capacity')"/>
                </td>
                <td>
                    <xsl:value-of select="TableDataDictionary:GetTableDataValue($i, 'Expected')"/>
                </td>
                <td>
                    <xsl:value-of select="TableDataDictionary:GetTableDataValue($i, 'TimeSpent')"/>
                </td>
                <td>
                    <xsl:value-of select="TableDataDictionary:GetTableDataValue($i, 'CompletedWork')"/>
                </td>
                <td>
                    <xsl:value-of select="TableDataDictionary:GetTableDataValue($i, 'TotalEstimate')"/>
                </td>
                <td>
                    <xsl:value-of select="TableDataDictionary:GetTableDataValue($i, 'ClosedTasks')"/>
                </td>
            </tr>
        </xsl:if>
        <xsl:if test="$i &lt;= $count">
            <xsl:call-template name="for-loop">
                <xsl:with-param name="i" select="$i + 1"></xsl:with-param>
                <xsl:with-param name="count" select="$count"></xsl:with-param>
            </xsl:call-template>
        </xsl:if>
    </xsl:template>
 
</xsl:stylesheet>
